package com.cf.r952_ak;

import java.io.*;

public class e {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StreamTokenizer in = new StreamTokenizer(br);
        PrintWriter out = new PrintWriter(System.out);
        in.nextToken(); int t = (int) in.nval;
        while (t-- > 0) {
            in.nextToken(); int x = (int) in.nval;
            in.nextToken(); int y = (int) in.nval;
            in.nextToken(); int z = (int) in.nval;
            in.nextToken(); long k = (long) in.nval;
            long ans = 0;
            for (int i = 1; i <= x; i++) {
                for (int j = 1; j <= y; j++) {
                    if (k % ((long) i * j) != 0) continue;
                    long a = k / ((long) i * j);
                    if (a > z) continue;
                    ans = Math.max(ans, (x - i + 1) * (y - j + 1) * (z - a + 1));
                }
            }
            out.println(ans);
        }
        out.flush();
        out.close();
        br.close();
    }
}
